package com.example.sourcesprng.jdk8._lambda._function;

import org.springframework.util.StringUtils;

import java.util.Locale;
import java.util.function.Function;

public class FunctionTest {

    public static void main(String[] args) {
        functionTest((param) -> {
            if (param.isBlank()) {
                return null;
            }
            return param.toUpperCase(Locale.ROOT);
        }, "qwer df");


        functionTest2((param) -> {
            Integer ints = -1;
            try {
                ints = Integer.valueOf(param);
            } catch (Exception e) {
                System.out.println("数据类型转换异常，请检查入参");
                return ints;
            }

            return ints * 5;
        }, "10");
    }

    public static void functionTest(Function<String, String> function, String param) {
        String qwer_df = function.apply(param);
        System.out.println(qwer_df);
    }

    public static void functionTest2(Function<String, Integer> function, String param) {
        Integer ints = function.apply(param);
        System.out.println(ints);
    }
}
